package service;

import dao.UserDao;

import java.util.HashMap;

public class UserService {
    private UserDao userDao = new UserDao();

    public boolean isLogin(String username, String password) {
        HashMap<String,String> user = userDao.getUserByUsername(username);
        System.out.println(user);
        if (user != null && user.get("password").equals(password)) {
            return true; // 密码匹配
        } else {
            return false; // 用户名不存在或密码不匹配
        }
    }

    public HashMap<String, String> getUserInfoByUsername(String username) {
        return userDao.getUserByUsername(username);
    }


    public String getUserRole(int userId) {
        String role = userDao.getUserRole(userId);
        if (role != null) {
            return role;
        } else {
            System.out.println("错误: 没有获取用户的权限");
            return null;
        }
    }
}